FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest

LABEL \
        org.opencontainers.image.title="keentuned-ui" \
        org.opencontainers.image.version="2.2.0" \
        maintainer="OpenAnolis KeenTune SIG"

RUN yum --nogpgcheck install httpd git npm gcc go -y

RUN git clone https://gitee.com/anolis/keentuned.git;cd keentuned; sh keentuned_install.sh
RUN git clone https://gitee.com/anolis/keentune_ui.git -b dev-2.1.0 \
    && cd keentune_ui; npm install --force \
    && npm run build \
    && mkdir -p /usr/share/keentune/html;cp -rf build /usr/share/keentune/html \
    && cp -f keentune.conf /etc/httpd/conf.d

RUN sed -i "0,/Require all denied*/s//#Require all denied/" /etc/httpd/conf/httpd.conf \
    && sed -i "0,/Listen 80/s//#Listen 80/" /etc/httpd/conf/httpd.conf \
    && sed -i ":a;N;$!ba;s%CustomLog \"logs/access_log\" combined*%#CustomLog \"logs/access_log\" combined%"  /etc/httpd/conf/httpd.conf \
    && sed -i "0,/LogLevel warn*/s//LogLevel crit/" /etc/httpd/conf/httpd.conf \
    && sed -i "0,/#ServerName/s//ServerName/" /etc/httpd/conf/httpd.conf

RUN cd keentuned;go clean --modcache \
    && cd ..;rm -rf keentuned keentune_ui \
    && yum remove go -y

